package com.air.ota.mo;

import java.util.HashMap;
import java.util.Map;

import com.air.common.exception.WrongFormatException;

public class BalanceTaskDetail {
	
	private Integer id;
	private Integer taskId;
	private String  sztBalanceInfo;
	private Integer transId;
	private Integer result;
	private String  descCn;
	private String  cardAppSequence;
	private String  transDate;
	private String  cardTransSequence;
	private Integer amount;
	
	private String  transType;
	private String  uncompleteTag;
	private Integer balanceStatus;
	private String  balanceStatusDesc;
	
	
	public static Map<Integer, String> _STATUS_DESC = new HashMap<Integer, String>();
	static{
		_STATUS_DESC.put(0, "对账成功");
		_STATUS_DESC.put(9, "人工平账");
		
		_STATUS_DESC.put(1001, "平台未找到交易记录");
		_STATUS_DESC.put(1002, "平台交易金额不匹配(平台金额:xx)");
		_STATUS_DESC.put(1003, "翼支付为找到交易记录");
		_STATUS_DESC.put(1004, "翼支付交易金额不匹配(翼支付金额:xx)");
	}
	
	public static Map<Integer, String> _BALANCE_STATUS_DESC = new HashMap<Integer, String>();
	static{
		_STATUS_DESC.put(0, "未进行结算");
		_STATUS_DESC.put(1, "结算完成");
		
		_STATUS_DESC.put(9, "其他");
	}
	
	public static final String _TRANS_TYPE_REG = "01"; //售卡
	public static final String _TRANS_TYPE_TRANSFER = "12";//转账充值
	public static final String _TRANS_TYPE_CANCEL = "71";//退卡/手机注销
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getTaskId() {
		return taskId;
	}
	public void setTaskId(Integer taskId) {
		this.taskId = taskId;
	}
	public String getSztBalanceInfo() {
		return sztBalanceInfo;
	}
	public void setSztBalanceInfo(String sztBalanceInfo) {
		this.sztBalanceInfo = sztBalanceInfo;
	}
	public Integer getTransId() {
		return transId;
	}
	public void setTransId(Integer transId) {
		this.transId = transId;
	}
	public Integer getResult() {
		return result;
	}
	public void setResult(Integer result) {
		this.result = result;
	}
	public String getDescCn() {
		return descCn;
	}
	public void setDescCn(String descCn) {
		this.descCn = descCn;
	}
	public String getCardAppSequence() {
		return cardAppSequence;
	}
	public void setCardAppSequence(String cardAppSequence) {
		this.cardAppSequence = cardAppSequence;
	}
	public String getTransDate() {
		return transDate;
	}
	public void setTransDate(String transDate) {
		this.transDate = transDate;
	}
	public String getCardTransSequence() {
		return cardTransSequence;
	}
	public void setCardTransSequence(String cardTransSequence) {
		this.cardTransSequence = cardTransSequence;
	}
	public Integer getAmount() {
		return amount;
	}
	public void setAmount(Integer amount) {
		this.amount = amount;
	}
	
	
	
	public String getTransType() {
		return transType;
	}
	public void setTransType(String transType) {
		this.transType = transType;
	}
	public String getUncompleteTag() {
		return uncompleteTag;
	}
	public void setUncompleteTag(String uncompleteTag) {
		this.uncompleteTag = uncompleteTag;
	}
	public Integer getBalanceStatus() {
		return balanceStatus;
	}
	public void setBalanceStatus(Integer balanceStatus) {
		this.balanceStatus = balanceStatus;
	}
	public String getBalanceStatusDesc() {
		return balanceStatusDesc;
	}
	public void setBalanceStatusDesc(String balanceStatusDesc) {
		this.balanceStatusDesc = balanceStatusDesc;
	}
	
	public void parse(String sztBalanceInfo) throws WrongFormatException{
		this.sztBalanceInfo = sztBalanceInfo;
		String[] datas=sztBalanceInfo.split(",");
		if (datas.length!=11){
			throw new WrongFormatException("Expect 11 Filed Data,But only get "+datas.length+" fields");
		}
		this.cardTransSequence = datas[0];//卡交易序号
		this.cardAppSequence = datas[5];//SZT 卡号
		this.transDate = datas[1];//交易时间
		this.amount = Integer.parseInt(datas[3]);//交易金额
		
		this.transType = datas[9];
		this.uncompleteTag = datas[10];
		
		cardTransSequence = Integer.toHexString(Integer.parseInt(cardTransSequence)).toUpperCase();
		for(int i=0;i<4-cardTransSequence.length();i++){
			cardTransSequence = "0"+cardTransSequence;
		}
		
		String tmpCardAppSequence = Integer.toHexString(Integer.parseInt(cardAppSequence)).toUpperCase();
		for(int i=0;i<8;i++){
			tmpCardAppSequence = "0"+tmpCardAppSequence;
		}
		cardAppSequence = "51800000"+tmpCardAppSequence;
		
		
	}
	
	
	
	
}
